{% extends "meetings/base_rooms_times.html" %}
{% load agenda_custom_tags tz %}
{% block subsection %}
{% timezone meeting.time_zone %}
    <div class="module">
        <h2>TimeSlots</h2>

        {% if assignments %}
            <table id="misc-sessions" class="full-width">
                <thead>
                    <tr>
                        <th scope="col">Day</th>
                        <th scope="col">Time</th>
                        <th scope="col">Name</th>
                        <th scope="col">Short Name</th>
                        <th scope="col">Group</th>
                        <th scope="col">Location</th>
                        <th scope="col">Show Loc.</th>
                        <th scope="col">Type</th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                        <th scope="col"></th>
                    </tr>
                </thead>
                <tbody>
                    {% for assignment in assignments %}
                        <tr class="{% cycle 'row1' 'row2' %}{% ifchanged assignment.session.type %} break{% endifchanged %}{% if assignment.current_session_status == "canceled" %} cancelled{% endif %}">
                            <td>{{ assignment.timeslot.time|date:"D" }}</td>
                            <td>{{ assignment.timeslot.time|date:"H:i" }}-{{ assignment.timeslot.end_time|date:"H:i" }}</td>
                            <td>{% assignment_display_name assignment %}</td>
                            <td>{{ assignment.session.short }}</td>
                            <td>{{ assignment.session.group.acronym }}</td>
                            <td>{{ assignment.timeslot.location }}</td>
                            <td>{{ assignment.timeslot.show_location }}</td>
                            <td>{% with purpose=assignment.session.purpose %}{{ purpose }}{% if purpose.timeslot_types|length > 1 %} ({{ assignment.slot_type }}){% endif %}{% endwith %}</td>
                            {% if assignment.schedule_id == schedule.pk %}
                                <td><a href="{% url "ietf.secr.meetings.views.misc_session_edit" meeting_id=meeting.number schedule_name=schedule.name slot_id=assignment.timeslot.id %}">Edit</a></td>
                                <td>
                                    {% if assignment.session.type.slug != "break" %}
                                        <a href="{% url "ietf.secr.meetings.views.misc_session_cancel" meeting_id=meeting.number schedule_name=schedule.name slot_id=assignment.timeslot.id %}">Cancel</a>
                                    {% endif %}
                                </td>
                                <td><a href="{% url "ietf.secr.meetings.views.misc_session_delete" meeting_id=meeting.number schedule_name=schedule.name slot_id=assignment.timeslot.id %}">Delete</a></td>
                            {% else %}
                                <td colspan="3" class="from-base-schedule">(from base schedule)</td>
                            {% endif %}
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        {% else %}
            <h3>No timeslots exist for this meeting. Add rooms with the "duplicate timeslots" option enabled to copy timeslots from the last meeting.</h3>
        {% endif %}
        <br><hr>

        <div>
            <form id="timeslot-form" method="post">{% csrf_token %}
                <table class="full-width amstable">
                    <tbody>
                    <!-- [html-validate-disable-block wcag/h63 -- FIXME: as_table renders without scope] -->
                    {{ form.as_table }}
                    <tr><td colspan="2" class="text-center"><button type="submit" name="submit">Add</button></td></tr>
                    </tbody>
                </table>
            </form>
        </div>

        <div class="button-group">
            <ul>
                <li><button type="button" onclick="window.location='../'">Back</button></li>
            </ul>
        </div> <!-- button-group -->

    </div> <!-- module -->

{% endtimezone %}
{% endblock %}

{% block extrahead %}
    {{ block.super }}
    {{ form.media.js }}
{% endblock %}
{% block extrastyle %}
    {{ form.media.css }}
{% endblock %}